function [ elite_individuals ] = elite( individuals, n_of_selection )
% ELITE 
%  Este metodo recibe una serie de individuos codificados como vectores y
%  devuelve un subconjunto de los n_of_selection mejores de acuerdo a la
%  funcion de fitness.

fitness_array = zeros(1, length(individuals));

for i = 1:length(individuals)
   fitness_array(i) = fitness(individuals{i});
end

ind_fitness = [fitness_array ; 1:length(individuals)];
[Y,I] = sort(ind_fitness(1,:), 'descend');
ind_fitness = ind_fitness(:,I);
individuals_indexes = ind_fitness(2,:);
elite_individuals = cell(1, n_of_selection);

for i = 1:n_of_selection
    elite_individuals{i} = individuals{individuals_indexes(i)};
end

end
